<template>
    <div id="parts">
        <el-table :data="dataList.slice((currentPage-1)*pagesize,currentPage*pagesize)" :highlight-current-row="true" stripe border class="table-index" :height="tableHeight" style="width: 100%;" :header-cell-style="getRowClass">
            <el-table-column fixed type="index" label="*" sortable min-width="40"></el-table-column>
            <el-table-column prop="name" label="姓名" sortable min-width="100"></el-table-column>
            <el-table-column prop="phone" label="电话" sortable min-width="170"></el-table-column>
            <el-table-column prop="email" label="邮箱" sortable min-width="200"></el-table-column>
            <el-table-column prop="content" label="内容" sortable min-width="600"></el-table-column>
        </el-table>
        <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange" :current-page="currentPage" :page-sizes="[5,10, 15,20, 25,30,50, 100]" :page-size="pagesize" layout="total, sizes, prev, pager, next, jumper" :total="dataList.length"></el-pagination>
    </div>
</template>

<script>
    export default {
        name: "MessageBoard",
        data() {
            return {
                tokenId: sessionStorage.getItem("tokenId"),
                currentPage: 1,
                pagesize: 10,
                tableHeight: document.documentElement.clientHeight - 130,
                dataList: [],
            };
        },
        created() {
            this.getData();
        },
        methods: {
            getData() {
                let _this = this;
                this.$http({
                    url: '/api/adscm/operation/messageboard/query?tokenId=' + _this.tokenId,
                    method: 'post',
                    headers: {'X-Requested-With': 'XMLHttpRequest'},
                }).then(function (res) {
                    if (res.data.statusCode == 200) {
                        _this.dataList = res.data.content;
                    } else {
                        _this.$message.error(res.data.desc);
                    }
                }).catch(function (catchres) {
                    _this.$message.error("加载失败！请重新加载...");
                })
            },
            handleSizeChange: function (size) {
                this.pagesize = size;
            },
            handleCurrentChange: function (currentPage) {
                this.currentPage = currentPage;
            },

        }
    }
</script>

<style scoped></style>
